<?xml version="1.0" encoding="windows-1255" ?>
<%@ page language="java" contentType="text/html; charset=windows-1255"
    pageEncoding="windows-1255"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<%@page import="java.util.List"%>
<%@page import="dataBase.magaers.CodeDBMngr"%>
<%@page import="dataBase.CidTitleVersion"%>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1255" />
<title>User Code</title>
</head>
<body>
<%  if (session.getAttribute("email") == null){ %>
		<jsp:forward page="login.jsp?valid=unsigned" />
<%	} %>
<%
	String email = (String)session.getAttribute("email"); 
	if (email == null){ %>
		<jsp:forward page="index.jsp?valid=unsigned" />
 <% } %>
	<h2>Hello <% out.print(email); %></h2> 
	<h3>Code that you own:</h3>
	<% 	CodeDBMngr cdbm = CodeDBMngr.getInstance(); 
		List<CidTitleVersion> codes = cdbm.getCodesByUser(email); 
		if ((codes != null) && (codes.size() > 0))
		{%>
			<table border="1">
				<tr><th>Title</th><th>Version</th><th>show code</th></tr>
		<%	for (CidTitleVersion ctv : codes)
			{ %>
				<tr>
				<td> <% out.print(ctv.getTitle()); %></td>
				<td> <% out.print(ctv.getVersion()); %></td>
				<td><a href="edv.jsp?cid=<% out.print(ctv.getCid()); %>&amp;version=<% out.print(ctv.getVersion()); %>" >show code</a></td>
				</tr>
		<% } %>
			</table>
	<% } %>
</body>
</html>